home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / db / esm-3.1 / esm-3 / usr / local / sm / src / serverlib / disk / diskReceive.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-05-05  |  3.2 KB  |  115 lines

  1. /*
  2.  *   $RCSfile: diskReceive.c,v $  
  3.  *   $Revision: 1.1.1.1 $  
  4.  *   $Date: 1996/05/04 21:55:38 $      
  5.  */ 
  6. /**********************************************************************
  7. * EXODUS Database Toolkit Software
  8. * Copyright (c) 1991 Computer Sciences Department, University of
  9. *                    Wisconsin -- Madison
  10. * All Rights Reserved.
  11. *
  12. * Permission to use, copy, modify and distribute this software and its
  13. * documentation is hereby granted, provided that both the copyright
  14. * notice and this permission notice appear in all copies of the
  15. * software, derivative works or modified versions, and any portions
  16. * thereof, and that both notices appear in supporting documentation.
  17. *
  18. * THE COMPUTER SCIENCES DEPARTMENT OF THE UNIVERSITY OF WISCONSIN --
  19. * MADISON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" CONDITION.  
  20. * THE DEPARTMENT DISCLAIMS ANY LIABILITY OF ANY KIND FOR ANY DAMAGES
  21. * WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
  22. *
  23. * The EXODUS Project Group requests users of this software to return 
  24. * any improvements or extensions that they make to:
  25. *
  26. *   EXODUS Project Group 
  27. *     c/o David J. DeWitt and Michael J. Carey
  28. *   Computer Sciences Department
  29. *   University of Wisconsin -- Madison
  30. *   Madison, WI 53706
  31. *
  32. *     or exodus@cs.wisc.edu
  33. *
  34. * In addition, the EXODUS Project Group requests that users grant the 
  35. * Computer Sciences Department rights to redistribute these changes.
  36. **********************************************************************/
  37. #include "sysdefs.h"
  38. #include "ess.h"
  39. #include "checking.h"
  40. #include "trace.h"
  41. #include "error.h"
  42. #include "list.h"
  43. #include "tid.h"
  44. #include "io.h"
  45. #include "lock.h"
  46. #include "object.h"
  47. #include "msgdefs.h"
  48. #include "disk.h"
  49. #include "thread.h"
  50. #include "semaphore.h"
  51. #include "latch.h"
  52. #include "link.h"
  53. #include "bf.h"
  54. #include "volume.h"
  55. #include "pool.h"
  56. #include "io_globals.h"
  57. #include "threadstate.h"
  58. #include "disk_funcs.h"
  59. #include "thread_funcs.h"
  60. #include "thread_globals.h"
  61. #include "queue_consist.h"
  62.  
  63.  
  64. /*
  65.  *    note that if an error is generated here then it will be
  66.  *    passed to all waiters but the link will not be called
  67.  */
  68.  
  69.  
  70.  
  71.  void
  72. diskReceive (
  73.     register LINK        *link
  74. )
  75.  
  76. {
  77.     register int        bytesRead;
  78.     char                volumenumber = 0xff;
  79.     extern        int        disk_replies_kicked;
  80.     extern        int        unnecessary_kicks;
  81.  
  82.     disk_replies_kicked++;
  83.  
  84.     /* 
  85.      * just read the disk queue# from the disk process
  86.      */
  87.     if((bytesRead = 
  88.         read(link->id, (caddr_t)(&volumenumber), sizeof(volumenumber))) <= 0) {
  89.         if(bytesRead==0)
  90.             errno = esmDISKPROCDIED;
  91.  
  92.         SM_ERROR(TYPE_STOP, errno); /* don't dump core because
  93.                 that would overwrite  the core file for the disk proc,
  94.                 which we then would be unable to debug.
  95.  
  96.                 BTW: what's below is really unreachable 
  97.                 since TYPE_STOP exits.
  98.                 Keep the code in here though, in case we decide to
  99.                 do something else instead of stop.
  100.             */
  101.         freeDiskLink(link, esmFAILURE, errno);
  102.         threadRestart();
  103.     } 
  104.  
  105.     diskReceiveQ( diskQueue((int)volumenumber), FALSE /* not holding mutex */); 
  106.  
  107.     /* 
  108.      * we get here only if there's really nothing on this queue 
  109.      * (i.e., it already got processed), which would be an error
  110.      * except that we might have caught some of the results
  111.      * in selectDisk(), so we just ignore this kick.
  112.      */
  113.     unnecessary_kicks++;
  114. }
  115.